package com.yoake.cine.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoake.common.annotation.Log;
import com.yoake.common.core.controller.BaseController;
import com.yoake.common.core.domain.AjaxResult;
import com.yoake.common.enums.BusinessType;
import com.yoake.cine.domain.MovieHall;
import com.yoake.cine.service.IMovieHallService;
import com.yoake.common.utils.poi.ExcelUtil;
import com.yoake.common.core.page.TableDataInfo;

/**
 * 影厅信息管理Controller
 * 
 * @author yoake
 * @date 2025-03-21
 */
@RestController
@RequestMapping("/cine/hall")
public class MovieHallController extends BaseController
{
    @Autowired
    private IMovieHallService movieHallService;

    /**
     * 查询影厅信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('cine:hall:list')")
    @GetMapping("/list")
    public TableDataInfo list(MovieHall movieHall)
    {
        startPage();
        List<MovieHall> list = movieHallService.selectMovieHallList(movieHall);
        return getDataTable(list);
    }

    /**
     * 导出影厅信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('cine:hall:export')")
    @Log(title = "影厅信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MovieHall movieHall)
    {
        List<MovieHall> list = movieHallService.selectMovieHallList(movieHall);
        ExcelUtil<MovieHall> util = new ExcelUtil<MovieHall>(MovieHall.class);
        util.exportExcel(response, list, "影厅信息管理数据");
    }

    /**
     * 获取影厅信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('cine:hall:query')")
    @GetMapping(value = "/{hallId}")
    public AjaxResult getInfo(@PathVariable("hallId") String hallId)
    {
        return success(movieHallService.selectMovieHallByHallId(hallId));
    }

    /**
     * 新增影厅信息管理
     */
    @PreAuthorize("@ss.hasPermi('cine:hall:add')")
    @Log(title = "影厅信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MovieHall movieHall)
    {
        return toAjax(movieHallService.insertMovieHall(movieHall));
    }

    /**
     * 修改影厅信息管理
     */
    @PreAuthorize("@ss.hasPermi('cine:hall:edit')")
    @Log(title = "影厅信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MovieHall movieHall)
    {
        return toAjax(movieHallService.updateMovieHall(movieHall));
    }

    /**
     * 删除影厅信息管理
     */
    @PreAuthorize("@ss.hasPermi('cine:hall:remove')")
    @Log(title = "影厅信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hallIds}")
    public AjaxResult remove(@PathVariable String[] hallIds)
    {
        return toAjax(movieHallService.deleteMovieHallByHallIds(hallIds));
    }
}
